#!/usr/bin/env python
#coding:utf-8

import sys
from PySide.QtCore import *
from PySide.QtGui import *

class Form(QDialog):

    def __init__(self, parent=None):
        super(Form, self).__init__(parent)
        self.setWindowTitle("My Form")

        # Create widgets
        self.edit = QLineEdit("Write my name here..")
        self.button = QPushButton("Show Greetings")

        self.buttonshowmsg = QPushButton("Show MessageBox Greetings")
        self.buttonclose = QPushButton("exit")

        # Create layout and add widgets
        layout = QVBoxLayout()
        layout.addWidget(self.edit)
        layout.addWidget(self.button)
        layout.addWidget(self.buttonshowmsg)
        layout.addWidget(self.buttonclose)
        # Set dialog layout
        self.setLayout(layout)

        # Add button signal to greetings slot
        self.button.clicked.connect(self.greetings)
        self.buttonshowmsg.clicked.connect(self.msgboxgreetings)
        self.buttonclose.clicked.connect(self.close)

        self.setWindowIcon(QIcon('about.jpg'))

    # Greets the user
    def greetings(self):
        print ("Hello %s" % self.edit.text())

    def msgboxgreetings(self):
        msgbox = QMessageBox()
        msgbox.setText(self.edit.text())
        msgbox.exec_()

if __name__ == '__main__':
    # Create the Qt Application
    app = QApplication(sys.argv)
    # Create and show the form
    form = Form()
    form.show()
    # Run the main Qt loop
    sys.exit(app.exec_())